<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【对战统计】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input name="accountNumber" type="hidden" th:value="${accountNumber}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>账号：</label>
                                <input type="text" id="accountNumber" name="accountNumber"/>
                            </li>
<!--                            <li>-->
<!--                                <label>分组：</label>-->
<!--                                <input type="text" name="groupId"/>-->
<!--                            </li>-->
                            <li>
                                <label>分组：</label>
                                <select id="groupId" name="groupId">
                                    <option value="">请选择分组</option>
                                    <option th:each=" group : ${groupings}"  th:text="${group.name}" th:value="${group.id}"></option>
                                </select>
                            </li>
                            <li>
                                <label>对战模式：</label>
                                <input type="text" id="againstType" name="againstType"/>
                            </li>
                            <li class="select-time">
                                <label>创建时间： </label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                            </li>

<!--                            <li>-->
<!--                                <label>收益：</label>-->
<!--                                <input type="text" name="earnings"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>每局收益：</label>-->
<!--                                <input type="text" name="hme"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>对战结果：</label>-->
<!--                                <input type="text" name="againstResults"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>登录的用户名：</label>-->
<!--                                <input type="text" name="userName"/>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="sub()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <table class="table table-striped" border="8" cellpadding="10" >-->
<!--                    <tr>-->
<!--                        <th>昨天</th>-->
<!--                        <th>今天</th>-->
<!--                        <th>账号总数</th>-->
<!--                        <th>总收益</th>-->
<!--                    </tr>-->
<!--                    <tr>-->
<!--                        <td th:text="${accountCount}"></td>-->
<!--                        <td>$100</td>-->
<!--                    </tr>-->
<!--                </table>-->
<!--                <div class="row">-->
<!--                    <div class="col-xs-12 col-sm-6 col-md-8">.col-xs-12 .col-sm-6 .col-md-8</div>-->
<!--                    <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>-->
<!--                </div>-->


<!--                <span class="label label-warning" th:text="昨日收益+':'+${yesterdayEarnings}"></span>-->
<!--                <span class="label label-warning" th:text="今日收益+':'+${todayEarnings}"></span>-->
<!--                <span class="label label-warning" th:text="账号总数+':'+${accountCount}"></span>-->

               <h2>合计:</h2><span class="label label-warning" id="spans" style="float: right;font-size: 20px">0</span>

<!--                <style>-->
<!--                    .label{-->
<!--                        font-size: 20px;-->
<!--                        right: inherit;-->
<!--                        margin-right: 30px;-->
<!--                    }-->
<!--                </style>-->
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:statistics:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:statistics:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:statistics:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:statistics:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:statistics:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:statistics:remove')}]];
        var prefix = ctx + "system/statistics";

        $(function() {

            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "【对战统计】",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '编号',
                    visible: true
                },
                {
                    field: 'accountNumber',
                    title: '账号'
                },
                {
                    field: 'name',
                    title: '分组'
                },
                {
                    field: 'earnings',
                    title: '收益'
                },

                // {
                //     field: 'hme',
                //     title: '每局收益'
                // },
                // {
                //     field: 'againstResults',
                //     title: '对战结果'
                // },
                // {
                //     field: 'againstType',
                //     title: '对战类型'
                // },
                // {
                //     field: 'userName',
                //     title: '登录的用户名'
                // },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        let startTime=$('#startTime').get(0).value;
                        let endTime=$('#endTime').get(0).value;
                        actions.push('<a class="btn btn-success btn-xs"  href="/system/statistics/particulars/'+row.accountNumber+'?startTime='+startTime+'&endTime='+endTime+'"><i class="fa fa-edit" ></i>详情</a> ');
                        console.log($('#startTime').get(0).value)
                        // actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="particulars(\'' + row.accountNumber + '\')"><i class="fa fa-remove"></i>详情</a>');

                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
            select();
        });
function sub(){
    select();
    $.table.search();
}
        function particulars(accountNumber){

            // $.modal.open("退款" + accountNumber, "/system/statistics/particulars/"+accountNumber);

            // $.operate.get("/system/statistics/particulars?accountNumber="+accountNumber);
        }
        function select(){
            console.log($('#againstType').get(0).value)
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "/system/statistics/selectHmeByTime",
                data: {againstType:$('#againstType').get(0).value,accountNumber:$('#accountNumber').get(0).value,groupId:$('#groupId').get(0).value,beginTime:$('#startTime').get(0).value,endTime:$('#endTime').get(0).value},
                success: function(data){
                    $("#spans").html(data)
                },
                error: function(msg){
                }

            });
        }
    </script>
</body>
</html>